home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: Turbo 3.0 compiler bug -- I MEAN IT!!!!
- Date: 3 Apr 1996 17:09:37 GMT
- Organization: Borland International
- Message-ID: <4jubch$52c@druid.borland.com>
- References: <4jpp78$85b@news.vanderbilt.edu> <4jr8m7$kpm@News.Dal.Ca>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4jr8m7$kpm@News.Dal.Ca>, Klaus.Eichele@Dal.Ca says...
- >
- >haseltbt@ctrvax.vanderbilt.edu (Bennett Haselton) wrote:
- >> Hello world,
- >
- >> i've found what appears to be a bug in the Turbo 3.0 C++
- >>compiler. Apparently if you write a while loop that is immediately preceded
- by
- >
- >>code identical to that contained in the while loop--and the "while" statement
- >>is true at the time the code immediately preceding it is analyzed--then the
- >>compiler ignores this extra code preceding the while loop as unnecessary.
- >>Seems reasonable--equivalent output, right?
- >> The problem is in the debugging process. i had written code with the
- >>above-mentioned redundancy to make it easier to read, and in the debugging
- >>cycle i tried setting breakpoints within the block of "redundant" code.
- Turbo
- >>C++ will not allow breakpoints to be set at empty or commented space;
- >>unfortunately the redundant code was compiled as "empty space" and
- breakpoints
- >>were forbidden there. Worse, when the compiler skipped to a breakpoint
- inside
- >>the while loop, it became obvious from the values of watch variables that the
- >>redundant code had been skipped entirely.
- > <SNIP>
- >
- >Hi, I don't think your discovery qualifies as a bug. For your
- >particular problem, however, you might want to try to switch of
- >optimization. Without optimization, you should get the result you
- >expect.
-
- To clarify a bit:
-
- InitialCode();
- while( Condition() )
- {
- SomeCode();
- InitialCode();
- }
-
- The compiler does tail merging here, and generates code as if you had written
- your code like this:
-
- goto Inner;
- while( Condition() )
- {
- SomeCode();
- Inner:
- InitialCode();
- }
-
- Both code sequences do the same thing. When you try to debug, though, it can be
- confusing, because the generated code doesn't directly correspond to the source
- code.
-
-